package pers.vic.xqd.provider;

import pers.vic.xqd.framerwork.Protocol;
import pers.vic.xqd.framerwork.ProtocolFactory;
import pers.vic.xqd.framerwork.Url;
import pers.vic.xqd.protocol.http.HttpProtocol;
import pers.vic.xqd.provider.api.HelloService;
import pers.vic.xqd.provider.impl.HelloServiceImpl;
import pers.vic.xqd.register.RemoteMapRegister;

import java.io.IOException;

/**
 * 描述:
 * @author Vic.xu
 * @date 2022-02-07 17:50
 */
public class Provider {

    public static void main(String[] args) throws IOException {
        String interfaceName = HelloService.class.getName();
        String hostname = "localhost";
        Integer port = 6666;
        //1. 本地注册
        //  (服务名:实现类)
        LocalRegister.regist(interfaceName, HelloServiceImpl.class);
        //2. 远程注册
        Url url = new Url(hostname, port);
        RemoteMapRegister.register(interfaceName, url);
        //3. 启动tomcat
        Protocol httpServer = ProtocolFactory.getProtocol();
        httpServer.start(url);

        System.in.read();

    }
}
